package vista;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

//import javax.swing.WindowConstants;
//import javax.swing.SwingUtilities;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaBuscaminas extends javax.swing.JFrame {
	
	private JPanel panelSup;
	private JPanel panelMedio;
	private JLabel lMinas;
	private JLabel lTiempo;
	private JMenuItem jMenuNivel;
	private JMenuItem jMenuSalir;
	private JMenuItem jMenuRecords;
	private JMenu jMenuConfig;
	private JMenuItem JMenuNueva;
	private JMenu jMenuNuevaPartida;
	private JMenuBar jMenuBar1;
	private JTextField txtTiempo;
	private JSeparator jSeparator1;
	private JTextField txtMinas;
	JButton[][] boton;
	

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaBuscaminas inst = new VistaBuscaminas();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VistaBuscaminas() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				
				setTitle("               Buscaminas                        ");	
				jMenuBar1 = new JMenuBar();
				setJMenuBar(jMenuBar1);
				{
					jMenuNuevaPartida = new JMenu();
					jMenuBar1.add(jMenuNuevaPartida);
					jMenuNuevaPartida.setText("Partida");
					{
						JMenuNueva = new JMenuItem();
						jMenuNuevaPartida.add(JMenuNueva);
						JMenuNueva.setText("Nueva");
						//JMenuNueva.addActionListener(this);
					}
					{
						jMenuRecords = new JMenuItem();
						jMenuNuevaPartida.add(jMenuRecords);
						jMenuRecords.setText("Records");
					}
					{
						jMenuSalir = new JMenuItem();
						jMenuNuevaPartida.add(jMenuSalir);
						jMenuSalir.setText("Salir");
					}
				}
				{
					jMenuConfig = new JMenu();
					jMenuBar1.add(jMenuConfig);
					jMenuConfig.setText("Configuración");
					{
						jMenuNivel = new JMenuItem();
						jMenuConfig.add(jMenuNivel);
						jMenuNivel.setText("Niveles");
					}
				}
			}
			{
				panelSup = new JPanel();
				{
					lMinas = new JLabel();
					panelSup.add(lMinas);
					lMinas.setText("Número de Minas:");
				}
				{
					
				}
				{
					txtMinas = new JTextField();
					panelSup.add(txtMinas);
					txtMinas.setColumns(3);
					//txtMinas.setText(Integer.toString(casillas));
					txtMinas.setEditable(false);
				}
				{
					lTiempo = new JLabel();
					panelSup.add(lTiempo);
					lTiempo.setText("Tiempo:");
				}
				{
					txtTiempo = new JTextField();
					panelSup.add(txtTiempo);
					txtTiempo.setColumns(3);
					txtTiempo.setText("0");
					txtTiempo.setEditable(false);
				}
			}
			{
				panelMedio=new JPanel(new GridLayout(100,100));
			//this.panelMedio = panelMedio;
				//GridLayout panelMedioLayout = new GridLayout(11, 11);
				//panelMedioLayout.setHgap(5);
				//panelMedioLayout.setVgap(5);
				//panelMedioLayout.setColumns(5);
				//panelMedio.setLayout(panelMedioLayout);
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addComponent(panelSup, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
				.addGap(17)
				.addComponent(panelMedio, 0, 306, Short.MAX_VALUE));
			thisLayout.setHorizontalGroup(thisLayout.createParallelGroup()
				.addComponent(panelSup, GroupLayout.Alignment.LEADING, 0, 572, Short.MAX_VALUE)
				.addComponent(panelMedio, GroupLayout.Alignment.LEADING, 0, 572, Short.MAX_VALUE));
			}
			pack();
			this.setSize(572, 430);
			
			
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void RedimensionarGrid(int filas, int columnas){
		panelMedio.setLayout(new GridLayout(filas,columnas));
		boton = new JButton [filas][columnas];
		panelMedio.setSize(columnas * 45, filas * 26);
		this.setSize(columnas * 48,filas * 40);
	}
	
	public JButton CrearBoton(){
		JButton boton = new JButton();
		return boton;
	}
		
    public JButton[][] getBoton() {
		return boton;
	}

	public void setBoton(JButton[][] boton) {
		this.boton = boton;
	}
	
	public JTextField getTxtTiempo() {
		return txtTiempo;
	}
	
	public String getTxtTiempo2() {
		return txtTiempo.getText();
	}
	
	public void setTxtTiempo(String txtTiempo) {
		this.txtTiempo.setText(txtTiempo);
	}

	public String getTxtMinas() {
		return txtMinas.getText();
	}

	public void setTxtMinas(String txtMinas) {
		this.txtMinas.setText(txtMinas);
	}
	
	public JPanel getPanelMedio() {
		return panelMedio;
	}

	public void setPanelMedio(JPanel panelMedio) {
		this.panelMedio = panelMedio;
		{
			jSeparator1 = new JSeparator();
			GridLayout jSeparator1Layout = new GridLayout(1, 1);
			jSeparator1Layout.setHgap(5);
			jSeparator1Layout.setVgap(5);
			jSeparator1Layout.setColumns(1);
			jSeparator1.setLayout(jSeparator1Layout);
			panelMedio.add(jSeparator1);
			jSeparator1.setPreferredSize(new java.awt.Dimension(572, 322));
		}
	}

	public void addListener(ActionListener actionListener) {
		jMenuSalir.addActionListener(actionListener);
		JMenuNueva.addActionListener(actionListener); 
		jMenuNivel.addActionListener(actionListener);
		jMenuRecords.addActionListener(actionListener);
    }
	
	 public void mostrarMensaje(String mensaje) {
		 JOptionPane.showMessageDialog(this, mensaje);
	 }

}


